//
//  YCTeachVideoCell.m
//  YCSchool
//
//  Created by Kylin on 16/5/1.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  视频教学的TableViewCell

#import "YCTeachVideoCell.h"
#import "YCVideoCell.h"
@interface YCTeachVideoCell()<UICollectionViewDataSource,UICollectionViewDelegate>
/**collectionView*/
@property(nonatomic,strong)UICollectionView *teachVideoView;
/**视频数组*/
@property(nonatomic,strong)NSMutableArray *videoArray;
@end

static NSString *const TeachVideoCell = @"TeachVideoCell";
static NSInteger const columnOfRow = 4;
static NSInteger const collectionViewH = 281;
@implementation YCTeachVideoCell

+ (CGFloat)getCellHeight{
    return 266;
}

- (NSMutableArray *)videoArray{
    if (!_videoArray) {
        _videoArray = [NSMutableArray arrayWithArray:
            @[@"http://img1.3lian.com/img13/c3/86/7.jpg",
              
              @"http://tx.haiqq.com/qqtouxiang/uploads/2013-08-07/110816568.jpg",
              
            @"http://scimg.jb51.net/allimg/160106/14-1601060933240-L.jpg",
              
            @"http://www.wzfzl.cn/uploads/allimg/150107/1-15010H006410-L.jpg"]];
    }
    return _videoArray;
}
- (UICollectionView *)teachVideoView{
    
    if (!_teachVideoView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        layout.scrollDirection = UICollectionViewScrollDirectionVertical;
        layout.minimumInteritemSpacing = 11;
        layout.minimumLineSpacing = 11;
        layout.itemSize = CGSizeMake((kScreenWidth - 41) /2, 105);
        layout.sectionInset = UIEdgeInsetsMake(15, 15, 30, 15);
        _teachVideoView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, collectionViewH ) collectionViewLayout:layout];
        _teachVideoView.dataSource = self;
        _teachVideoView.delegate = self;
        _teachVideoView.pagingEnabled = YES;
        _teachVideoView.backgroundColor = [UIColor whiteColor];
        _teachVideoView.showsHorizontalScrollIndicator = NO;
        _teachVideoView.showsVerticalScrollIndicator = NO;
        [_teachVideoView registerClass:[YCVideoCell class] forCellWithReuseIdentifier:TeachVideoCell];

    }
    
    return _teachVideoView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = YCRandomColor
        [self.contentView addSubview:self.teachVideoView];
    }
    
    return self;
}

#pragma mark-UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return columnOfRow;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    YCVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:TeachVideoCell forIndexPath:indexPath];
    cell.Bgimage = self.videoArray[indexPath.row];
    return cell;
}

@end
